package listbyorder.access001_100.test11;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/6 14:34
 */
public class Solution2 {

    // 方法一的基础上优化
    public int maxArea(int[] height) {
        int ans = 0;
        int l = 0;
        int r = height.length - 1;
        while (l < r) {
            ans = Math.max(ans, Math.min(height[l], height[r]) * (r - l));
            if (height[l] < height[r]) {
                l++;
            } else {
                r--;
            }
        }
        return ans;
    }
}
